package com.potenza.training.dictionary.server.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.potenza.training.dictionary.dao.ProjectTechnologyDao;
import com.potenza.training.dictionary.entity.ProjectTechnology;
import com.potenza.training.dictionary.server.ProjectTechnologyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("projectTechnologyServiceImpl")
public class ProjectTechnologyServiceImpl extends ServiceImpl<ProjectTechnologyDao, ProjectTechnology> implements ProjectTechnologyService {

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private ProjectTechnologyDao projectTechnologyDao;

    @Override
    public List<ProjectTechnology> findAll() {
        Object projectTechnology = redisTemplate.opsForValue().get("projectTechnology");
        if (projectTechnology==null){
            List<ProjectTechnology> list = this.list();
            redisTemplate.opsForValue().set("projectTechnology", list);
            return list;
        }

        return (List<ProjectTechnology>)projectTechnology;
    }

}